package chp13.home;

import java.util.Scanner;

public class Home1 {

    public static void main(String[] args) {
//        String str = "0891-1234567";
//        String[] aa = str.split("-");
//        System.out.println(aa.length);
//        System.out.println(aa[0].length());
//        System.out.println(aa[1].length());

        Scanner input = new Scanner(System.in);
        System.out.println("**欢迎进入注册系统***");
        String phone = "";
        String mobile = "";
        String idCard = "";
        while (true) {
            System.out.print("请输入座机号:");
            phone = input.next();
            if(phone.length() == 12){
                //0891-1234567
                String[] arr = phone.split("-");
                if(arr.length == 2 && arr[0].length()==4 && arr[1].length()==7){
                    break;
                }
            }
            System.out.println("座机号不符合要求..");

        }

        while (true) {
            System.out.print("请输入手机号:");
            mobile = input.next();
            if(mobile.length()==11){
                break;
            }
            System.out.println("手机号不符合要求.");
        }

        while (true) {
            System.out.print("请输入身份证:");
            idCard = input.next();
            if (idCard.length() == 15 || idCard.length() == 18) {
                break;
            }else{
                System.out.println("身份证不符合要求.");
            }
        }

        System.out.println("注册成功");
        System.out.println("身份证:" + idCard);
        System.out.println("手机号:" + mobile);
        System.out.println("座机号:" + phone);
    }
}
